﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Common;
using System.Data.OleDb;

namespace ArkEC.SEMs.DataAccess.MLM.Implement.Access
{
    /// <summary>
    /// 语言资源的数据库操作接口的实现类
    /// </summary>
    public class LanResourceDA_Acs : ILanResourceDA
    {
        /// <summary>
        /// 根据数据表来统计语言资源
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="tran"></param>
        /// <param name="tableName"></param>
        /// <returns></returns>
        public DataTable GetLanResStat(DbConnection conn, DbTransaction tran, string tableName)
        {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandText = @"SELECT LRCode, count(*) as LanResCount from " + tableName + " Group by LRCode";

            DataSet ds = new DataSet();
            OleDbDataAdapter adp = new OleDbDataAdapter(cmd as OleDbCommand);
            adp.Fill(ds);

            return ds.Tables[0];
        }

        /// <summary>
        /// 获取所有语言资源
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="tran"></param>
        /// <returns></returns>
        public DataTable QuerySysValueRes(DbConnection conn, DbTransaction tran)
        {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandText = @"SELECT * from SysValue_Res";

            DataSet ds = new DataSet();
            OleDbDataAdapter adp = new OleDbDataAdapter(cmd as OleDbCommand);
            adp.Fill(ds);

            return ds.Tables[0];
        }
    }
}
